import {http as api} from "slash-admin";
import {ApiResponse, ListResponse} from "slash-admin";
import {PageQueryParam, SearchKeyQueryParam} from "slash-admin";


export interface AuthTbPostResponse {
        id:string,
        postCode:string,
        postName:string,
        postSort:number,
        status:string,
        remark:string,
        createTime:string,
        updateTime:string,
        createUserAccount:string,
        updateUserAccount:string,
    }
export interface SelectAuthTbPostPageListQueryParam extends SearchKeyQueryParam {

}

/**
 * 分页查询列表
 * @param query
 */
export const selectPageList = (query: SelectAuthTbPostPageListQueryParam): Promise<ListResponse<AuthTbPostResponse>> => {
    return api.doGet('/AuthApp/AuthTbPost/selectPageList', query)
}
/**
 * 分页查询列表
 * @param query
 */
export const selectList = (query: SelectAuthTbPostPageListQueryParam): Promise<ListResponse<AuthTbPostResponse>> => {
    return api.doGet('/AuthApp/AuthTbPost/selectList', query)
}
/**
 * 根据ID查询
 * @param id
 */
export const selectById = (id: string|number): Promise<ApiResponse<AuthTbPostResponse>> => {
    return api.doGet('/AuthApp/AuthTbPost/selectById', {id: id})
}


/**
 * 新增
 * @param data
 */
export const doSaveEntity = (data: any): Promise<ApiResponse<boolean>> => {
    return api.doPost('/AuthApp/AuthTbPost/save', data)
}
/**
 * 实体
 * @param data
 */
export const doUpdateEntity = (data: any): Promise<ApiResponse<boolean>> => {
    return api.doPost('/AuthApp/AuthTbPost/update', data)
}
/**
 * 逻辑删除
 * @param id|ids
 */
export const doLogicDeleteEntity = (ids: Array<string | number> | number | string): Promise<ApiResponse<boolean>> => {
    let data:any = null;
    if (Array.isArray(ids)) {
        data = ids;
    } else {
        data = [ids];
    }
    return api.doPost('/AuthApp/AuthTbPost/logicDelete', data)
}
/**
 * 物理删除
 * @param id|ids
 */
export const doDeleteEntity = (ids: Array<string> | number | string): Promise<ApiResponse<boolean>> => {
    let data:any = null;
    if (Array.isArray(ids)) {
        data = ids;
    } else {
        data = [ids];
    }
    return api.doPost('/AuthApp/AuthTbPost/delete', data)
}

export default {
    selectList,
    selectPageList,
    selectById,
    doDeleteEntity,
    doLogicDeleteEntity,
    doUpdateEntity,
    doSaveEntity,
}
